/**
 * 
 */
package br.com.mkmts.business.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import br.com.mkmts.business.AgendaBO;
import br.com.mkmts.dao.cadastro.AgendaDao;
import br.com.mkmts.dto.AgendaDTO;
import br.com.mkmts.model.AgendaEntity;
import br.com.mkmts.utils.Adapter;

/**
 * @author christopher.rozario
 *
 */

@Service
public class AgendaBOImpl implements AgendaBO{

	@Autowired
	private AgendaDao dao = null;

	@Override
	public AgendaDTO addAgenda(AgendaDTO dto) {
		return Adapter.entityToDto(getDao().insert(Adapter.dtoToEntity(dto)));
	}
	
	@Override
	public List<AgendaDTO> listarAgenda() {
		List<AgendaEntity> entities = getDao().findAll();
		List<AgendaDTO> returnzz = new ArrayList<AgendaDTO>();
		for (int i = 0; i < entities.size(); i++) {
			returnzz.add(Adapter.entityToDto(entities.get(i)));
		}
		
		return returnzz;
	}
	
	@Override
	public void atualizarAgenda(AgendaDTO dto) {
		getDao().update(Adapter.dtoToEntity(dto));
	}
	
	public AgendaDao getDao() {
		return dao;
	}

	public void setDao(AgendaDao dao) {
		this.dao = dao;
	}

}
